import { CONFIG_PREFIX_SEPARATOR } from "@smithy/shared-ini-file-loader";
import { IniSectionType, ParsedIniData } from "@smithy/types";

export const getMockProfileData = (profileName: string) =>
[1, 2, 3]
  .map((num) => [`key_${profileName}_${num}`, `value_${profileName}_${num}`])
  .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});

export const getMockOutput = (profileNames: string[]) =>
profileNames.reduce((acc, profileName) => ({ ...acc, [profileName]: getMockProfileData(profileName) }), {});

export const getMockInput = (mockOutput: Record<string, Record<string, string>>) =>
Object.entries(mockOutput).reduce(
  (acc, [key, value]) => ({ ...acc, [[IniSectionType.PROFILE, key].join(CONFIG_PREFIX_SEPARATOR)]: value }),
  {}
);

export const combineParsedIniData=(data1:ParsedIniData,data2:ParsedIniData):ParsedIniData=>{
  return {
    ...data1,
    ...data2
  }
}


export const getMockSsoSessionData = (ssoSessionName: string) =>
[1, 2, 3]
  .map((num) => [`key_${ssoSessionName}_${num}`, `value_${ssoSessionName}_${num}`])
  .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});

export const getMockSsoOutput = (ssoSessionNames: string[]) =>
ssoSessionNames.reduce((acc, profileName) => ({ ...acc, [profileName]: getMockSsoSessionData(profileName) }), {});

export const getMockSsoInput = (mockOutput: { [key: string]: { [key: string]: string } }) =>
Object.entries(mockOutput).reduce(
  (acc, [key, value]) => ({ ...acc, [[IniSectionType.SSO_SESSION, key].join(CONFIG_PREFIX_SEPARATOR)]: value }),
  {}
);